<?php
class Admin_CategoryController extends My_Controller_Admin_Action
{
	protected $categoryModel = '';

	protected function _init()
	{
		$this->categoryModel = new Admin_Model_Category();
	}

	public function indexAction()
	{
	    $num_vente = $this->_getParam('num_vente');
		$rowPerPage = $this->_getParam('rowperpage', 20);
		$currentPage = 1;
		$page = $this->_getParam('page', 1);
		if(!empty($page)) {
			$currentPage = $page;
		}

		$rows = $this->categoryModel->getListCategory($num_vente);
		$paginator = Zend_Paginator::factory($rows);
		$paginator->setItemCountPerPage($rowPerPage);
		$paginator->setCurrentPageNumber($currentPage);
		
		$this->view->page = $page;
		$this->view->paginator = $paginator;
	    $this->view->num_vente = $num_vente;
	}
	
	public function addAction()
	{
		$id = $this->_getParam('num');
		
		if(!$id)
		{
			$this->view->title = "Ajout d'une catégorie";
		}else{
			$this->view->title = 'Editer une catégorie';
			$cate = new Admin_Model_Category();
			$row = $cate->getCategory($id);
			$this->view->cate = $row;
		}
	}
	
	public function precAction()
	{
		
	}
	
	public function saveAction()
	{
		
	}
}

